package com.learn.transaction_control.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class AccountDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    
    public void incrMoney(int id, int money) {
        jdbcTemplate.update(
                "UPDATE account SET money = money+? WHERE id = ?", money, id
        );
    }
    
    public void decrMoney(int id, int money) {
        jdbcTemplate.update(
                "UPDATE account SET money = money-? WHERE id = ?", money, id
        );
    }
}
